package com.ruoyi.asms.controller;

import com.ruoyi.asms.domain.AsmsFaultFeedbackStage;
import com.ruoyi.asms.service.IAsmsFaultFeedbackStageService;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.security.annotation.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 故障反馈阶段信息Controller
 * 
 * @author yfkj
 * @date 2021-10-21
 */
@RestController
@RequestMapping("/asms/AsmsFaultFeedbackStage")
public class AsmsFaultFeedbackStageController extends BaseController
{
    @Autowired
    private IAsmsFaultFeedbackStageService asmsFaultFeedbackStageService;

    /**
     * 查询故障反馈阶段信息列表
     */
    @PreAuthorize
    //@PreAuthorize(hasPermi = "asms:AsmsFaultFeedbackStage:list")
    @GetMapping("/list")
    public TableDataInfo list(AsmsFaultFeedbackStage asmsFaultFeedbackStage)
    {
        startPage();
        List<AsmsFaultFeedbackStage> list = asmsFaultFeedbackStageService.selectAsmsFaultFeedbackStageList(asmsFaultFeedbackStage);
        return getDataTable(list);
    }

    /**
     * 导出故障反馈阶段信息列表
     */
    @PreAuthorize
    //@PreAuthorize(hasPermi = "asms:AsmsFaultFeedbackStage:export")
    @Log(title = "故障反馈阶段信息", businessType = BusinessType.EXPORT)
    @PostMapping(value="/export", produces = "application/octet-stream")
    public void export(HttpServletResponse response, AsmsFaultFeedbackStage asmsFaultFeedbackStage) throws IOException
    {
        List<AsmsFaultFeedbackStage> list = asmsFaultFeedbackStageService.selectAsmsFaultFeedbackStageList(asmsFaultFeedbackStage);
        ExcelUtil<AsmsFaultFeedbackStage> util = new ExcelUtil<AsmsFaultFeedbackStage>(AsmsFaultFeedbackStage.class);
        util.exportExcel(response, list, "故障反馈阶段信息数据");
    }

    /**
     * 获取故障反馈阶段信息详细信息
     */
    @PreAuthorize
    //@PreAuthorize(hasPermi = "asms:AsmsFaultFeedbackStage:query")
    @GetMapping(value = "/{faultFeedbackStageId}")
    public AjaxResult getInfo(@PathVariable("faultFeedbackStageId") Long faultFeedbackStageId)
    {
        return AjaxResult.success(asmsFaultFeedbackStageService.selectAsmsFaultFeedbackStageByFaultFeedbackStageId(faultFeedbackStageId));
    }

    /**
     * 新增故障反馈阶段信息
     */
    @PreAuthorize
    //@PreAuthorize(hasPermi = "asms:AsmsFaultFeedbackStage:add")
    @Log(title = "故障反馈阶段信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AsmsFaultFeedbackStage asmsFaultFeedbackStage)
    {
        return toAjax(asmsFaultFeedbackStageService.insertAsmsFaultFeedbackStage(asmsFaultFeedbackStage));
    }

    /**
     * 修改故障反馈阶段信息
     */
    @PreAuthorize
    //@PreAuthorize(hasPermi = "asms:AsmsFaultFeedbackStage:edit")
    @Log(title = "故障反馈阶段信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AsmsFaultFeedbackStage asmsFaultFeedbackStage)
    {
        return toAjax(asmsFaultFeedbackStageService.updateAsmsFaultFeedbackStage(asmsFaultFeedbackStage));
    }

    /**
     * 删除故障反馈阶段信息
     */
    @PreAuthorize
    //@PreAuthorize(hasPermi = "asms:AsmsFaultFeedbackStage:remove")
    @Log(title = "故障反馈阶段信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{faultFeedbackStageIds}")
    public AjaxResult remove(@PathVariable Long[] faultFeedbackStageIds)
    {
        return toAjax(asmsFaultFeedbackStageService.deleteAsmsFaultFeedbackStageByFaultFeedbackStageIds(faultFeedbackStageIds));
    }
}
